<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">



    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <style>

        .numberBox{
          display: inline-block;
            border:1px solid #eee;
            padding:5px;
            width: 30%;
            text-align: center;
            font-weight: bold;
            margin-left:5px;
            height: 30px;
        }

        .ibox-content .row{

            margin:10px 0;
        }
        .func-item{
            border: 1px solid #eee;
            width: 100px;
            height: 100px;
            text-align: center;
            position: relative;
            font-weight: bold;
            margin:10px 0px;
            cursor: pointer;
        }
        .func-item img{

            width: 40%;
            margin:20px 0px;
            margin-bottom: 10px;

        }
        .ibox-button{

            position: absolute;
            right: 30px;
            top: 15px;
        }
        th{
            text-align: center;
        }

    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div style="width: 100%;display: inline-block">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h4> 单品替换</h4>
                        </div>


                        <div class="ibox-content" style=";height: 250px;padding-right: 5%;">
                            <div class="row row-lg">
                                <div>
                                    <div class="col-sm-2">

                                    <label class="col-sm-12 control-label">原始数码：</label>

                                    </div>
                                    <div class="col-sm-5">
                                        <input id="code" class="form-control" placeholder="输入原始数码"/>

                                    </div>
                                    <div class="col-sm-2">

                                        <button class="btn btn-success" onclick="search()">查询</button>
                                    </div>
                                </div>
                            </div>
                            <div class="row row-lg">
                                <div>
                                    <div class="col-sm-2">

                                        <label class="col-sm-12 control-label">箱码：</label>

                                    </div>
                                    <div class="col-sm-5">
                                        <input id="tihuancode" class="form-control" placeholder="输入替换数码"/>

                                    </div>
                                    <div class="col-sm-1">

                                        <button class="btn btn-success" onclick="buda()">补打箱码</button>


                                    </div>


                                    <div class="col-sm-2">
                                        <input id="bumaNum" class="form-control" placeholder="通用补码数量"/>

                                    </div>
                                    <div class="col-sm-1">

                                        <button class="btn btn-success" onclick="budaCommon()">通用补打</button>


                                    </div>
                                </div>
                            </div>
                            <div style="overflow: auto;overflow-x: hidden;height: 100%;margin-top:10px;">
                                <table class="table table-striped" style="text-align: center;margin:0 10px; ">
                                    <thead>
                                    <tr>
                                        <th>
                                            托码
                                        </th>
                                        <th>
                                            箱码
                                        </th>
                                        <th>
                                            盒码
                                        </th>
                                        <th>
                                            产品名称
                                        </th>
                                        <th>
                                            品项
                                        </th>
                                        <th>
                                            采集时间
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody id="tbody">





                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </div>

    </div>


    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="js/plugins/validate/jquery.validate.min.js"></script>
    <script src="js/plugins/validate/messages_zh.min.js"></script>
    <script src="js/plugins/layer/layer.min.js"></script>
    <script src="js/tm/edit.js"></script>
    <script>
        window.onload = function(){
        }

        function search(){
           let code =  $("#code").val();
            sendData("/produce/queryChildCode",{code:code},function(res){
                if(res.code == 200){
                    let data = res.data;
                    if(data.data =='0'){
                        layer.msg("无相关数据");
                    }else{
                        let childCode = data.child_code;
                        let xiang_code = data.xiang_code;
                        let duo_ma = data.duo_ma;
                        let createTime = data.create_time;
                        let task = data.task;
                        let productName = data.pinxiang
                        let typeName = data.kouwei;
                        $("#tbody").html("");
                        $("#tbody").append("<tr><td>"+duo_ma+"</td><td>"+xiang_code+"</td><td>"+childCode+"</td><td>"+productName+"</td><td>"+typeName+"</td><td>"+createTime+"</td></tr>")
                        $("#tihuancode").val(xiang_code);
                    }
                }
            });
        }

        function buda(){
            let tihuancode = $("#tihuancode").val();
            if(!tihuancode){
                layer.msg("请输入正确的箱码");
                return;
            }
            sendData("/produce/buda",{tihuanCode:tihuancode},function(res){
                  if(res.data.status){
                      layer.msg("补打成功");
                  }else{
                      layer.msg("补打失败，请检查码是否输入正确");
                  }
            });
        }

        function sendData(url,data,callback){
                $.ajax({
                    url:"http://127.0.0.1:8090/"+url,
                    type: 'POST', // 请求类型
                    data: data, // 发送JSON字符串
                    success:function(res){
                        callback(res);
                    }
                })
        }

            function renderData(data) {
                $("#total").html(data.childTotal);
                $("#successTotal").html(data.successTotal);
                $("#xiangTotal").html(data.xiangTotal);
                if(!data.xiangCode.trim()){
                    data.xiangCode = "暂无"
                }

                $("#xiangCode").html(data.xiangCode);

                $("#rate").html(data.rate);
                $("#productName").html(data.productName);
                $("#typeName").html(data.productType);
                let scanList = data.scanList;
                $("#xiangIndex").html(scanList.length);
                $("#tbody").html("");
                for (let i = 0; i < scanList.length; i++) {
                    $("#tbody").append('<tr><td>' + scanList[i] + '</td></tr>');
                }
            }

            function budaCommon(){
                let val = $("#bumaNum").val();
                if(val<1){
                    layer.msg("请输入大于0的数量");
                    return;
                }
                sendData("/produce/addBuData?num="+val,{},function(res){
                    layer.confirm("请连续放置"+val+"箱进行贴码",{btn:["确定"]});
                })

            }
    </script>
</body>

</html>
